import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class term4 {
    public static void main(String[] args) {
        String filePath = "your_source_code_file.txt"; // 替换为你的文件路径
        List<String> strings = extractStrings(filePath);
        for (String str : strings) {
            System.out.println(str);
        }
    }

    public static List<String> extractStrings(String filePath) {
        List<String> extractedStrings = new ArrayList<>();
        StringBuilder currentString = new StringBuilder();
        boolean inString = false;
        boolean escapeNext = false;

        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
            int currentChar;
            while ((currentChar = reader.read()) != -1) {
                char c = (char) currentChar;

                if (escapeNext) {
                    // 如果上一个字符是反斜杠，则此字符将被添加到当前字符串
                    currentString.append(c);
                    escapeNext = false; // 重置状态
                } else {
                    switch (c) {
                        case '"':
                            if (inString) {
                                // 结束字符串
                                extractedStrings.add(currentString.toString());
                                currentString.setLength(0); // 清空当前字符串
                                inString = false; // 退出字符串状态
                            } else {
                                // 开始字符串
                                inString = true;
                            }
                            break;
                        case '\\':
                            escapeNext = true; // 下一字符需要转义
                            break;
                        default:
                            if (inString) {
                                currentString.append(c); // 在字符串内添加字符
                            }
                            break;
                    }
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return extractedStrings;
    }
}